package com.zilu.digitaltwin.dto.dataq;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;

/**
 * @ClassName: UnitRoomDataQRespDTO
 * @Description:
 * @Author: 段振宇
 * @Date: 2023/1/9 17:03
 */
@Data
public class UnitRoomDataQRespDTO {

    @JSONField(name = "room_id")
    private String roomId;

    @JSONField(name = "room_num")
    private String roomNum;

    @JSONField(name = "floor_num")
    private String floorNum;

    @JSONField(name = "unit_num")
    private String unitNum;

    @JSONField(name = "room_use_type_no")
    private String roomUseTypeNo;

    /**
     * 楼层的起始高度
     */
    @JSONField(name = "cur_floor_start_height")
    private Float floorStartHeight;

    /**
     * 户室坐标系
     */
    @JSONField(name = "room_geojson_info")
    private String geoJsonInfo;

    /**
     * 楼层坐标系
     */
    @JSONField(name = "floor_geojson_info")
    private String floorGeoJsonInfo;

    /**
     * 楼层的高度
     */
    @JSONField(name = "floor_height")
    private Float floorHeight;

    private JSONObject feature;

    private JSONObject floorFeature;

    public String getUnitNum() {
        if (unitNum == null) {
            unitNum = "独栋";
        }
        return unitNum;
    }

    public String getFloorNum() {
        if (floorNum == null) {
            floorNum = "0";
        }
        return floorNum;
    }


    /**
     * @return 楼层结束（天花板）高度
     */
    public Float getFloorEndHeight() {
        if (null == floorHeight && null == floorStartHeight) {
            return null;
        }
        return (null == floorHeight ? 0 : floorHeight) + (null == floorStartHeight ? 0 : floorStartHeight);
    }

    public JSONObject getFeature() {
        if (null == geoJsonInfo || geoJsonInfo.trim().isEmpty()) {
            return null;
        }
        try {
            return null != feature ? feature : (feature = JSONObject.parseObject(geoJsonInfo));
        } catch (Exception e) {
            return null;
        }
    }

    public JSONObject getFloorFeature() {
        if (null == floorGeoJsonInfo || floorGeoJsonInfo.trim().isEmpty()) {
            return null;
        }
        try {
            return null != floorFeature ? floorFeature : (floorFeature = JSONObject.parseObject(floorGeoJsonInfo));
        } catch (Exception e) {
            return null;
        }
    }

}
